Chapter 5 - Terraform Language Basics
Intro to HCL
Terraform Configuration Syntax
.tf 99% of the time .tf.json 1% of the time
These are called terraform configuration files or terraform manifests
Written in HCL - Hashicorp Language
left side is the identifier, the right side is called the expression.
name = "myRG"
Comments are ## or // or /* multiline comment */
Terraform Arguments (Meta) and Attributes
Arguments = inputs (required or optional) Attributes - Timeouts - allow you to specify a timeout for specific CRUD actions Import - resources that exist in the cloud that aren't managed by Terraform
Meta Arguments
- depends on
- count
- for_each
- provider
- lifecycle
Terraform Top level blocks
Most of terraform's features are top level blocks.
- Fundamental
- terraform
- providers
- resources
- Variable
- input
- output
- local values
- Calling/Reference blocks
- data sources
- modules
Demo Code for Blocks
Look at the different types of the blocks in the Git 04 folder, and identify how many labels you have on each block. Some have 0, 1, 2 labels.
Multiple types of blocks Ctrl+Space will give you a list of them.
Get used to using Ctrl+Space to define your blocks:
Required arguments will appear in the list and you can select them from the dropdowns.
There is an option to turn on prefill required arguments in the Hashicorp Terraform Extension settings. Try to use this whenever you can, but expect that it may not work all of the time.
You can use syntax highlighting by mousing over the specific parts and get tooltips.